package fr.generali.accueilclient.gwt.client.model;

import java.util.Set;

import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;

public abstract class ModelCallback<T>  {

	public abstract void onSuccess(T result);
	
	public void onFailure(Throwable reason) {
		
	}
	
	public void onConstraintViolation(Set<ConstraintViolation<?>> violations){
    if (!violations.isEmpty()) {
    	onFailure(new ConstraintViolationException(violations));
    }
	}

}
